#ifndef _AGENDA_CONTROLLER_CPP
#define _AGENDA_CONTROLLER_CPP

#include "AgendaController.h"
#include <string>
#include <list>
#include <iostream>
using namespace std;


AgendaController::AgendaController()
{

}


void AgendaController::getOperation( void )
{

}


void AgendaController::startAgenda( void )
{
	this->agendaService_.startAgenda();
}


bool AgendaController::executeOperation( std::string op )
{
	/**
	#Before Login:
	l   - log in Agenda by user name and password
	r   - register an Agenda account
	//q   - quit Agenda

	#After Login:
	o   - log out Agenda
	dc  - delete Agenda account
	lu  - list all Agenda user
	cm  - create a meeting
	la  - list all meetings
	las - list all sponsor meetings
	lap - list all participator meetings
	qm  - query meeting by title
	qt  - query meeting by time interval
	dm  - delete meeting by title
	da  - delete all meetings
	**/

	// check if login, then catch command ..
	if(currentUser_==NULL) {
		// state: logout ..
		if(op=="l") {this->userLogIn(); return true;}
		if(op=="r") {this->userRegister(); return true;}
	}
	else {
		// state: login ..
		if(op=="o") {this->userLogOut(); return true;}
		if(op=="dc") {this->deleteUser(); return true;}
		if(op=="lu") {this->listAllUsers(); return true;}
		if(op=="cm") {this->createMeeting(); return true;}
		if(op=="la") {this->listAllMeetings(); return true;}
		if(op=="las") {this->listAllSponsorMeetings(); return true;}
		if(op=="lap") {this->listAllParticipateMeetings(); return true;}
		if(op=="qm") {this->queryMeetingByTitle(); return true;}
		if(op=="qt") {this->queryMeetingByTimeInterval(); return true;}
		if(op=="dm") {this->deleteMeetingByTitle(); return true;}
		if(op=="da") {this->deleteAllMeetings(); return true;}
	}

	// catch no valid command, return false ..
	return false;
}



#endif // !_AGENDA_CONTROLLER_CPP
